/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow: hidden;
}

/* Main container - adapts to iframe or full window */
#main-container {
    width: 100%;
    height: 100vh;
    display: grid;
    grid-template-columns: 1fr 280px;
    grid-template-rows: 1fr auto;
    grid-template-areas: 
        "canvas controls"
        "canvas data";
    gap: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

/* Iframe detection and height adjustment */
@media (max-height: 500px) {
    #main-container {
        height: 450px;
    }
}

/* Canvas styling */
#simulation-canvas {
    grid-area: canvas;
    background: linear-gradient(to bottom, #87CEEB 0%, #98FB98 70%, #8FBC8F 100%);
    border: 2px solid #fff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Control panel styling */
#control-panel {
    grid-area: controls;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-item label {
    font-size: 12px;
    font-weight: 600;
    color: #444;
    cursor: help;
}

/* Slider styling */
.slider {
    width: 100%;
    height: 20px;
    border-radius: 10px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
    background: #5a6fd8;
    transform: scale(1.1);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Button styling */
.button-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-button {
    flex: 1;
    min-width: 100px;
    height: 40px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.fire-btn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
}

.fire-btn:hover {
    background: linear-gradient(135deg, #ff5252, #e55100);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.fire-btn:active {
    transform: translateY(0);
}

.reset-btn {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    color: white;
}

.reset-btn:hover {
    background: linear-gradient(135deg, #6c5ce7, #5f3dc4);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(116, 185, 255, 0.3);
}

/* Data panel styling */
#data-panel {
    grid-area: data;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.data-header {
    font-size: 14px;
    font-weight: bold;
    color: #444;
    margin-bottom: 8px;
    text-align: center;
    cursor: help;
}

.data-grid {
    display: grid;
    gap: 6px;
}

.data-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 4px;
}

.data-label {
    font-size: 11px;
    font-weight: 600;
    color: #555;
}

.data-value {
    font-size: 11px;
    font-weight: bold;
    color: #667eea;
    font-family: 'Courier New', monospace;
}

/* Tooltip styling */
.tooltip-display {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    max-width: 200px;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tooltip-display.show {
    opacity: 1;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    #main-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto auto;
        grid-template-areas: 
            "canvas"
            "controls"
            "data";
        height: 90vh;
    }
    
    #control-panel {
        max-height: 120px;
        overflow-y: auto;
    }
    
    .control-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    
    .button-group {
        grid-column: 1 / -1;
    }
    
    .data-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
    }
}

/* Touch-friendly sizing */
@media (pointer: coarse) {
    .slider {
        height: 24px;
    }
    
    .slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    
    .action-button {
        height: 44px;
        font-size: 16px;
    }
}